<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<s:url value="/css/style.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery-1.3.2.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.bgiframe.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.ajaxQueue.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/thickbox-compressed.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.autocomplete.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/tableSel.js"/>"></script>
			<script type='text/javascript'
			src="<s:url value="/js/common.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/jquery.autocomplete.css"/>" />
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/thickbox.css"/>" />
		<script type="text/javascript" src="<s:url value="/js/jquery-ui.js"/>"></script>
		<link href="<s:url value="/css/jquery.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery.blockUI.js"/>"></script>
		<script type="text/javascript">
		function dosubmit(){
		    $('#listForm').submit();
		}
		function changedisplay(el){
			el.toggle("fast",function() {
				 //$Container.getContainerProxy().resize();
			});
		}
		function goAddNew(){
			location.href='<s:url value="/customer/Visit/edit"/>';
		};
		function doShowAll(form){
			form = document.getElementById('listForm');
			var ids = getSelectionIds('a');
			if(ids.length<1){
				alert('Please select one at least.');
			}else{
				$('#dialog').dialog('open');
				
			}
		};
		//新加一个学生
        function doAddStudent(){
              var  sid=  $("#selstudentid").val();
		      var  sn= $("#selstudentName").val();
		      var  st= $("#selstudentTel").val();
		      var  ss= $("#selstudentStatus").val();
		      if (!sid||!sn){
	             alert("please select one student");
	             return;
	          };
	          $('#studentTable').append("<tr id='"+sid+"'></tr>");
			  $("#studentTable")
						.find("tr:last")
						.append("<td class=\"tablecolour2\">"
								+"<input type=\"checkbox\" name=\"a\" value=\""
								 +sid+"\"/></td><td class=\"tablecolour2\">" 
							    + sn+ "</td><td class=\"tablecolour2\">"
							    + st+ "</td><td class=\"tablecolour2\"></td>"
							    + "<td class=\"tablecolour2\"></td>"
							    + "<td class=\"tablecolour2\"></td>"
							     + "<td class=\"tablecolour2\"></td>"
							    + "<td class=\"tablecolour2\"></td><td class=\"tablecolour2\">"
							    + ss+"</td><td class=\"tablecolour2\"  style=\"cursor:pointer\""
									+ "  onclick=\"doDeleteStudent('"
									+ sid + "');\">Del</td>");
        };
        function doDeleteStudent(clsId){
	    	   $("#"+clsId).remove();
		};
		$(document).ready(function(){
		if ($.trim($('#result').text()) != '') {
			popupDiv('pop-div');
		};
		$('#dialog').hide();
		$('#dialog').dialog({
			bigiframe:true,
			autoOpen:false,
			modal:true,
			buttons:{
				'Show Up':function(){
			form = document.getElementById('listForm');
			form.action=form.action.replace('list','showAll');
			var ids = getSelectionIds('a');
			$('#ids').val(ids);
			$('#suc').val($('#showUpComments').val());
			form.submit();
			},
			'Cancel':function(){
				$('#dialog').dialog('close');
				$(this).dialog('close');
				}
			}

			});
			$('#dialog2').hide();
			$('#dialog2').dialog({
				bigiframe:true,
				autoOpen:false,
				modal:true,
				buttons:{
					'Unshow':function(){
						form = document.getElementById('listForm2');
						
						$('#suc2').val($('#showUpComments2').val());
						form.submit();
					},
					'Cancel':function(){
						$('#dialog2').dialog('close');
						$(this).dialog('close');
					}
				}
			});
		    $('#selCreateStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selCreateEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selLastTouchStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selLastTouchEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selSetApptStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selSetApptEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selShowStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selShowEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selAssignTmStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selAssignTmEndTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selInitVisitStartTime').datepicker( {dateFormat :'yy-mm-dd'});
		    $('#selInitVisitEndTime').datepicker( {dateFormat :'yy-mm-dd'});
            $("#selMarketingPlan").autocomplete("<s:url value="/marketing/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selMarketingPlan").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selMarketingPlanId").val(d.id);
            });
            $("#selAdChannel").autocomplete("<s:url value="/data/AdChannel/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selAdChannel").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selAdChannelId").val(d.id);
            });
            $("#selPTE").autocomplete("<s:url value="/data/PTE/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name+" "+d.wno;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name+" "+d.wno;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selPTE").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selPTEId").val(d.id);
            });
              $("#selTM").autocomplete("<s:url value="/system/User/autoCompleteTMAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name+" "+d.wno;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name+" "+d.wno;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
             $("#selTM").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selTMId").val(d.id);
            });
               $("#selPTELead").autocomplete("<s:url value="/data/PTE/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selPTELead").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selPTELeadId").val(d.id);
            });
            $("#selCreateUser").autocomplete("<s:url value="/system/User/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      var d=eval("("+row+")");
			      return  d.name;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
     	       }
            });
            $("#selCreateUser").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selCreateUserId").val(d.id);
            });
            $("#selstudent").autocomplete("<s:url value="/customer/Leads/autoCompleteAjax.action"/>", {
               width: 300,
               minChars:2, //几个字
               mastMatch:true,
               selectFirst: false,
               max:  20,
           	   formatItem: function(row, i, max) {
           	      //alert(row);
           	      var d=eval("("+row+")");
           	      //alert(d);
			      return  d.name+ " " + d.tel;
	          },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
 			     return  d.name+ " " + d.tel;
		      },
		      formatResult: function(row) {
		        // alert(row);
		         var d=eval("("+row+")");
			     return d.name+" "+ d.tel ;
     	       }
            });
            $("#selstudent").result(function(event, data, formatted) {
           	      var d=eval("("+data+")");
		          $("#selstudentid").val(d.id);
		          $("#selstudentName").val(d.name);
		          $("#selstudentTel").val(d.tel);
		          $("#selstudentStatus").val(d.status);
            });
        });
       	function goDetail() {
			   var sid=$("#selstudentid").val();
			   if (!sid){
			      alert("please select a  student ");
			      return ;
			   }
		 	   var url="<%=basePath%>customer/PersonalTouch/visitEdit?id="+sid;
		 	   var aa=window.open(url);  
	    };
	   function goView(id) {
			   var url="<%=basePath%>customer/PersonalTouch/visitEdit?id="+id;
		 	   var aa=window.open(url);  
	    };
	    function doExport(obj){
		    form = document.getElementById('listForm');
			var tmp =	form.action ;
			//alert(form.action);
			form.action = form.action.replace('reportPage','exportReport');
			//alert(form.action);
			form.submit();
			form.action = tmp;
	    }
		</script>
		<title><s:text name="system.title" />
		</title>
	</head>
	<body>
		<s:include value="/common/up.jsp"></s:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="box">
					<s:form action="Visit/reportPage" name="listForm" id="listForm"
						namespace="/customer">
						<input type="hidden" id="startIndex" name="startIndex" value="0" />
						<s:hidden name="ids" id="ids" />
						<s:hidden name="suc" id="suc" />
						<table width="100%" border="0" cellpadding="0" cellspacing="0"
							class="searchbg">
							<tr>
								<td>
									Show Time:
										<s:textfield id="selShowStartTime"
											name="selShowStartTime" cssClass="input2" size="10" />
										-
										<s:textfield id="selShowEndTime" name="selShowEndTime"
											cssClass="input2" size="10" />
									School:
								 	<s:select id="school" name="selSchoolId"  list="schoolList" />
								 	<img onClick="doExport(this);" src="<s:url value="/img/right/Export.gif"/>" border="0" align="absmiddle" id="exportimg" /> 
								</td>
								</tr>
						</table>
					</s:form>
				</td>
			</tr>
		</table>
	</body>
</html>